#pragma once
#include <vector>
#include "Animation.h"
using namespace std;

class Bone
{
	public:
		Bone();
		Bone(float aAngle, float aLength, float aWidth, Bone* aParent);
		Bone(const Bone& b);
		~Bone();

		Bone& operator=(const Bone& b);

		Bone* GetParent() {return parent;};
		Bone* GetChild(unsigned int aI);
		int GetChildCount() {return childs.size();};
		Bone* AddChild(float aAngle, float aLength, float aWidth);

		float GetLength() {return length;};
		float GetLengthMultiplier() {return lengthMultiplier;};
		float GetRealLength() {return length*lengthMultiplier;};
		float GetAngle() {return angle;};
		float GetX() {return x;};
		float GetY() {return y;};
		float GetJointX();
		float GetJointY();
		float GetWidth() {return width;};
		void SetLength(float aLength);
		void SetAngle(float aAngle);

		void SetKeyFrame(KeyFrame* aKeyFrame) {keyFrame = aKeyFrame;};
		void Tick();

	private:
		float angle;
		float length;
		float lengthMultiplier;
		float x;
		float y;

		float width;

		vector<Bone*>childs;
		Bone* parent;

		KeyFrame* keyFrame;
		float angleBefore;
		float lengthBefore;
		bool isAnimating;
		int animationFrame;

		void SetX(float aX) {x = aX;};
		void SetY(float aY) {y = aY;};
};